//
//  WFBaseNavigationViewController.m
//  谷居
//
//  Created by dllo on 16/6/16.
//  Copyright © 2016年 刘万方. All rights reserved.
//

#import "WFBaseNavigationViewController.h"

@interface WFBaseNavigationViewController ()

@end

@implementation WFBaseNavigationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (instancetype)initWithRootViewController:(UIViewController *)rootViewController {
    self = [super initWithRootViewController:rootViewController];
    if (self) {
        self.navigationBar.translucent = NO;
        [self setColor];
        [self addObserver];
    }
    return self;
}
- (void)setColor {
    if (!IS_LONG) {
        self.navigationBar.barTintColor = DAY_COLOR;
    } else {
        self.navigationBar.barTintColor = NIGHT_COLOR;
    }
    
}

- (void)addObserver {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeToNight:) name:@"夜间模式" object:nil];
    
}
-(void)changeToNight:(NSNotification *)sender {
    if (!IS_LONG) {
        self.navigationBar.barTintColor = NIGHT_COLOR;
    } else {
        self.navigationBar.barTintColor = DAY_COLOR;
    }
}
- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"夜间模式" object:nil];
//    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
